﻿using HalconDotNet;
using System;
using System.Windows.Controls;

namespace DetectApp.Display
{
    public abstract class ROIControl
    {
        public EventHandler? ROIChange;
        public string RegionGuid { get; set; }

        public abstract ROIParam GetParam();

        public abstract HRegion? GetRegion();

        public abstract ROIInfo GetROI();
        public abstract void Remove();
    }

    public class ROIFactory
    {

        public static ROIControl? CreateROI(Canvas canvas, ROIParam? rOIParam)
        {
            if (rOIParam is null) return null;
            switch (rOIParam.ROIType)
            {
                case ROIType.矩形:

                    return new Rectangle2Control(canvas, rOIParam);

                case ROIType.圆:
                    return new CircleControl(canvas, rOIParam);

                case ROIType.直线:
                    return new LineControl(canvas, rOIParam);

                case ROIType.无:
                    break;
                case ROIType.完整圆环:
                    return new RingCircleControl(canvas, rOIParam);

                case ROIType.圆弧:
                    return new ArcControl(canvas, rOIParam);

                case ROIType.圆环:
                    return new RingControl(canvas, rOIParam);

                case ROIType.封闭曲线:
                    return new CloseCurveControl(canvas, rOIParam);

                case ROIType.多边形:
                    return new PolygonControl(canvas, rOIParam);

                default:
                    break;
            }
            return null;
        }
    }
}